package lj.courseinterect.transfer;

import lj.courseinterect.entity.AnswerInfo;
import lj.courseinterect.entity.Student;

/**
 * Created by CatoldCui on 2015/5/24.
 */
public class AnswerTransfer {
    public static int MAXLENGTH = 40;
    boolean isShortAnswer = false;
    AnswerInfo answerInfo;
    Student student;

    public AnswerTransfer(){

    }

    public AnswerTransfer(boolean isShortAnswer){
        this.isShortAnswer = isShortAnswer;
    }

    public AnswerInfo getAnswerInfo() {
        return answerInfo;
    }

    public void setAnswerInfo(AnswerInfo answerInfo) {
        if(answerInfo != null){
            if(isShortAnswer){
                // 判断是否缩短
                String ans = answerInfo.getAnsName();
                if(ans.length() > MAXLENGTH){
                    answerInfo.setAnsName(ans.substring(0, MAXLENGTH) + "...");
                }
            }
        }
        this.answerInfo = answerInfo;
    }

    public Student getStudent() {
        return student;
    }

    public void setStudent(Student student) {
        if(student != null){
            student.setStuPwd("");
        }
        this.student = student;
    }

    public boolean isShortAnswer() {
        return isShortAnswer;
    }

    public void setShortAnswer(boolean isShortAnswer) {
        this.isShortAnswer = isShortAnswer;
    }
}
